﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Commonlib;
namespace DAL
{
    public class ClothBuyDAL
    {
        //获取布料购买信息
        public DataTable getClothBuy(string limit)
        {
            string cmdstr = "select * from ClothBuy where 1=1 and "+limit;
            return SqlHelper.ExecuteDataSet(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null).Tables[0];
        }

        //添加一条total后的布料购买信息（statusID=1/No Status）显示到邮件发送页面
        public void addClothBuy(Albon.Model.ClothBuy clothbuy)
        {
            SqlParameter[] parameters = new SqlParameter[] {
					new SqlParameter("@clothRefNo", clothbuy.clothRefNo),
					new SqlParameter("@orderRefNo", clothbuy.orderRefNo),
					new SqlParameter("@clothCompany",clothbuy.clothCompany),
					new SqlParameter("@clothNo", clothbuy.clothNo),
					new SqlParameter("@clothSize", clothbuy.clothSize),
					new SqlParameter("@itemClothList", clothbuy.itemClothList)
            };
            SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnectionString, CommandType.StoredProcedure, "p_clothbuyadd", parameters);
        }

        //将布料购买信息标记为已发送邮件（statusID=2/Wait），不再显示到邮件发送页面
        public void buyCloth(string buyclothlist)
        {
            string cmdstr = "update ClothBuy set statusID=2 where ID in ("+buyclothlist+")";
            SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null);
        }

        //修改布料状态 
        public void updateStatus(string id,string statusID)
        {
            string cmdstr = "update ClothBuy set statusID=" + statusID + " where ID=" + id;
            SqlHelper.ExecuteNonQuery(SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null);
        }
    }
}
